package chen.javaee_experiment3.Controller;

import chen.javaee_experiment3.Entity.VirusData;
import chen.javaee_experiment3.Service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@RestController
@ResponseBody
public class PageController {

    @Autowired
    private SearchService SearchService;

    @RequestMapping("/index.html")
    public ModelAndView startWithKey(@RequestParam(name = "key", required = false) String key){
        List<VirusData> virusDataList = SearchService.startWithKey(key);
        return new ModelAndView("index.html", "virusDataList", virusDataList);
    }
}
